﻿using System;

namespace ExampleCodesLib
{
    public class ClockAngles
    {
        /// <summary>
        /// A function to calculate the angle betwwen the hour hand and minute hand.
        /// The hour hand turns 0.5 degree per minute and the minute hand turns 6 degree per minute.
        /// The equation: |0.5*(hours*60+minutes)-minutes*6|=|30*hours-5.5*minutes|
        /// </summary>
        /// <param name="hours">hour time</param>
        /// <param name="minutes">minutes time</param>
        /// <returns>degrees: 0-360</returns>
        public static double CalAngles(int hours, int minutes)
        {
            double degrees = 0;
            if ((hours >= 0 && hours < 24) && (minutes >= 0 && minutes < 60))
            {
                if (hours > 12)
                {
                    hours = hours - 12;
                }
                degrees = Math.Abs(30 * hours - 5.5 * minutes);
            }
            else
            {
                throw new ArgumentException("Hour value should be between 0-23, Minute value should be between 0-59");
            }
            return degrees;
        }
    }
}
